﻿@model PagedList<View_CashOrder>
@{
    ViewBag.Title = "提现订单列表";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";

    CashOrderQueryModel paramModel = new CashOrderQueryModel();
    if (ViewBag.paramModel != null)
    {
        paramModel = (CashOrderQueryModel)ViewBag.paramModel;
    }
    ADZ_MasterEntities dbcontext = new ADZ_MasterEntities();
    Dictionary<string, string> dc = new Dictionary<string, string>();
}
<div style="width:100%;left:0;top:0;height:100%;position:fixed; display:none;" class="bui-ext-mask"></div>

<form id="S_Form" class="form-inline definewidth m20" action="@Url.Action("getlist", "cashorder")" method="get">
    <div class="form_query">
        <div>
            代购编号：
            <input type="text" name="replace_buyer_NO" id="replace_buyer_NO" class="abc input-default" placeholder="" value="@paramModel.replace_buyer_NO">&nbsp;
        </div>
        <div>
            会员手机号：
            <input type="text" name="account_mobile" id="account_mobile" class="abc input-default" placeholder="" value="@paramModel.account_mobile">&nbsp;
        </div>
        <div>
            会员名称：
            <input type="text" name="member_name" id="member_name" class="abc input-default" placeholder="" value="@paramModel.member_name">&nbsp;
        </div>
        <div>
            提现订单号：
            <input type="text" name="order_no" id="order_no" class="abc input-default" placeholder="" value="@paramModel.order_no">&nbsp;
        </div>

        <div>
            订单状态：
            <select id="status" name="status">
                <option value="-10" @(paramModel.status == -10 ? "selected" : "")>全部状态</option>
                @{
                    dc = new Dictionary<string, string>();
                    var statuslist = YiYiTong.Rocket.Helper.EnumHelper.GetEnumItems(typeof(CashOrderStatus));
                    foreach (var item in statuslist)
                    {
                        dc.Add(item.Value.ToString(), item.Description);
                    }
                }
                @HtmlPagerHelper.ShowSelectOpton(dc, paramModel.status.ToString());
            </select>&nbsp;
        </div>
        <div>
            下单时间：
            <input type="text" name="beg_time" class="calendar calendar-time" id="beg_time" value="@paramModel.beg_time.ToString(1)"> - <input type="text" name="end_time" class="calendar calendar-time" id="end_time" value="@paramModel.end_time.ToString(1)">&nbsp;
        </div>
        <div>
            @{Html.RenderPartial(Url.Content("~/Views/Common/PageSize.cshtml"), paramModel);}
        </div><div>
            <button type="submit" class="btn btn-primary">查询</button>&nbsp;&nbsp;
        </div>
    </div>
</form>

<table class="table table-bordered table-hover definewidth m10">
    <thead>
        <tr>
            <th>代购编号</th>
            <th>会员手机号</th>
            <th>会员名称</th>
            <th>提现订单号</th>
            <th>提现金额</th>
            <th>订单状态</th>
            <th>下单时间</th>
            <th>提现银行</th>
            <th>开户支行</th>
            <th>开户人</th>
            <th>银行账户</th>
            <th>操作</th>
        </tr>
    </thead>
    @if (Model != null && Model.Count != 0)
    {
        int index = 0;
        foreach (var m in Model)
        {
            index++;
            <tr class="@HtmlPagerHelper.TrClass(index)">
                <td>@m.replace_buyer_NO</td>
                <td>@m.account_mobile</td>
                <td>@m.member_name</td>
                <td>@m.order_no </td>
                <td>@m.cash_amt </td>
                <td>
                    @{
                        int order_status = ConvertHelper.ConvertTo<int>(m.status, 0);
                        switch (order_status)
                        {
                            case (int)CashOrderStatus.Create:
                                @:<div>@(MyEnumHelper.GetEnumItemDescription<CashOrderStatus>(order_status))</div>
                                break;
                            case (int)CashOrderStatus.AuditSucc:
                                @:<div class="green">@(MyEnumHelper.GetEnumItemDescription<CashOrderStatus>(order_status))</div>
                                break;
                            case (int)CashOrderStatus.AuditFail:
                                @:<div class="red">@(MyEnumHelper.GetEnumItemDescription<CashOrderStatus>(order_status))</div>
                                break;
                            case (int)CashOrderStatus.GiveMoney:
                                @:<div class="green">@(MyEnumHelper.GetEnumItemDescription<CashOrderStatus>(order_status))</div>
                                        break;
                        }
                    }
                </td>
                <td>@m.create_time.ToString(1)</td>
                <td>@m.bank_name</td>
                <td>@m.branch_bank_name</td>
                <td>@m.bank_account_name</td>
                <td>@m.bank_account</td>
                <td>
                    @if (m.status == (int)CashOrderStatus.Create)
                    {
                        @:<a href="javascript:void(0);" data-id="@m.order_id" data-msg="@m.reason" class="btnedit">审核</a>
                    }
                    @if (m.status == (int)CashOrderStatus.AuditSucc)
                    {
                        @:<a href="javascript:void(0);" onclick="Give(@m.order_id)">汇款</a>
                    }
                </td>
            </tr>
        }
     }
</table>
<div id="markDiv" class="hidden">
    <form id="form" class="form-horizontal">
        <input type="hidden" id="txtorder_id" />
        <div id="divMark" style="display:none;" class="row">
            <div class="tips tips-small tips-warning span2">
                <span class="x-icon x-icon-small x-icon-error"><i class="icon icon-white icon-bell"></i></span>
                <div class="tips-content">
                    审核驳回
                </div>
            </div>
            <div class="control-group span12" style="margin-top:10px;">
                <hr style="border:none;border-top:1px ridge #000000;" />
            </div>
            <div class="control-group span12">
                <label class="control-label">
                    驳回原因
                </label>
                <div class="controls control-row4">
                    <textarea id="txtreason" class="input-large" data-rules="{required : true}"></textarea>
                </div>
            </div>
            <div class="control-group">
                <a class="button button-success" style="float:right;margin: -30px 40px;" onclick="Reject()">提交</a>
            </div>
        </div>
    </form>
</div>
<div class="inline pull-left total">
    总行数：@ViewData["AllCount"] | 总提现金额：@ViewData["AllCashAmt"]
</div>
<div class="inline pull-right page">
    @if (Model != null)
    {
        @Html.Pager(Model, HtmlPagerHelper.BasePagerOption)
    }
</div>
<script>
    reloadHandler = function () {
        window.location.reload();
    }

    BUI.use(['bui/form', 'bui/overlay'], function (Form, overlay) {
        new Form.Form({
            srcNode: '#S_Form'
        }).render();

        //弹出框
        var dialog = new overlay.Dialog({
            title: '提现审核',
            width: 500,
            height: 410,
            //配置DOM容器的编号
            contentId: 'markDiv',
            mask: false,
            buttons: [
                 {
                     text: '审核通过',
                     elCls: 'button button-success',
                     handler: function () {
                         url = "@Url.Action("audit", "cashorder")";
                         parameter = {
                             order_id: $('#txtorder_id').val(),
                             status: 10,
                             msg: ""
                         };
                         $.post(url, parameter, function (result) {
                             ShowActionResult(result, reloadHandler);
                         });
                         $('.bui-ext-mask').hide();
                         $('#txtreason').html('');
                         this.close();
                     }
                 },{
                     text: '审核驳回',
                     elCls: 'button button-warning',
                     handler: function () {
                         var bhhtml = $(".bui-stdmod-body").eq(0).clone();
                         $(".bui-stdmod-body").eq(0).remove();
                         $(".bui-stdmod-footer").eq(0).after(bhhtml);

                         $(".bui-stdmod-body").eq(0).fadeIn();
                         $("#divMark").fadeIn();
                     }
                 }
            ],
            success: function () {
                this.close();
            }
        });

        $('.btnedit').on('click', function () {
            $("#divMark").hide();
            $('.bui-ext-mask').show();
            id = $(this).attr("data-id");
            msg = $(this).attr("data-msg");

            $('#txtorder_id').val(id);
            $('#txtreason').val(msg);
            dialog.show();
            $("#form").parent().hide();
            //弹出层关闭遮罩层
            $('.bui-ext-close').on('click', function () {
                $('#txtreason').html('');
                $('.bui-ext-mask').hide();
            });
        });
    });

    function callBack() {
        window.document.location.reload();
    }

    function Reject() {
        url = "@Url.Action("audit", "cashorder")";
        parameter = {
            order_id: $('#txtorder_id').val(),
            status: 20,
            msg: $('#txtreason').val()
        };
        $.post(url, parameter, function (result) {
            ShowActionResult(result, reloadHandler);
        });
        $('.bui-ext-mask').hide();
        $('#txtreason').html('');
        this.close();
    };

    function Give(id)
    {
        BUI.Message.Show({
            title: '提示',
            msg: '确定要将更改汇款标识吗?',
            icon: 'question',
            buttons: [
                {
                    text: '确定',
                    elCls: 'button button-primary',
                    handler: function () {
                        url = "@Url.Action("give", "cashorder")";
                        parameter = { order_id: id };
                        $.post(url, parameter, function (result) {
                                ShowActionResult(result, reloadHandler);
                                });
                                this.close();
                            }
                        },
              {
                            text: '取消',
                  elCls: 'button',
                  handler: function () {
                                this.close();
                            }
                        }

            ]
        });
    }
</script>

